import { cookies } from 'next/headers';

export function getIsLogin() {
  const cookiesObj = cookies();
  const token = cookiesObj.get('token')?.value;
  const expireTime = Number(cookiesObj.get('token_expire_time')?.value) || 0;
  const isExpired = new Date(expireTime).getTime() < new Date().getTime();
  const isLogin = !!token && !isExpired;
  return isLogin;
}

export function getCookie(name: string) {
  const cookiesObj = cookies();
  return cookiesObj.get(name)?.value || '';
}
